package com.ruoyi.system.common;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Result<T> {
    private Integer code;
    private String msg;
    private Object data;
//    private List<T> dataList;
//    private Map<String, Object> dataMap = new HashMap<>();

    private Result(Object data) {
        this.data = data;
    }

//    private Result(List<T> dataList) {
//        this.dataList = dataList;
//    }

//    private Result(Map<String, Object> dataMap) {
//        this.data = dataMap;
//    }

    public Result() {
    }


    public static Result success() {
        Result tResult = new Result();
        tResult.setCode(ResultCodeEnum.SUCCESS.code);
        tResult.setMsg(ResultCodeEnum.SUCCESS.msg);
        return tResult;
    }

    public static Result success(Object data) {
        Result tResult = new Result (data);
        tResult.setCode(ResultCodeEnum.SUCCESS.code);
        tResult.setMsg(ResultCodeEnum.SUCCESS.msg);
        return tResult;
    }

//    public static Result success(List dataList) {
//        Result tResult = new Result (dataList);
//        tResult.setCode(ResultCodeEnum.SUCCESS.code);
//        tResult.setMsg(ResultCodeEnum.SUCCESS.msg);
//        return tResult;
//    }

//    public static Result success(Map<String, Object> dataMap) {
//        Result tResult = new Result (dataMap);
//        tResult.setCode(ResultCodeEnum.SUCCESS.code);
//        tResult.setMsg(ResultCodeEnum.SUCCESS.msg);
//        return tResult;
//    }

    public static Result error() {
        Result tResult = new Result();
        tResult.setCode(ResultCodeEnum.SYSTEM_ERROR.code);
        tResult.setMsg(ResultCodeEnum.SYSTEM_ERROR.msg);
        return tResult;
    }

    public static Result error(Integer code, String msg) {
        Result tResult = new Result();
        tResult.setCode(code);
        tResult.setMsg(msg);
        return tResult;
    }

    public static Result error(ResultCodeEnum resultCodeEnum) {
        Result tResult = new Result();
        tResult.setCode(resultCodeEnum.code);
        tResult.setMsg(resultCodeEnum.msg);
        return tResult;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

//    public List<T> getDataList() {
//        return dataList;
//    }
//
//    public void setDataList(List<T> dataList) {
//        this.dataList = dataList;
//    }
//
//    public Map<String, Object> getDataMap() {
//        return dataMap;
//    }
//
//    public void setDataMap(Map<String, Object> dataMap) {
//        this.dataMap = dataMap;
//    }
}
